package com.gui.juc.base.thread.method;

import com.gui.utils.Sleeper;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

@Slf4j
public class InterrupterDemo1 {

    public static void main(String[] args) {

        Thread t1 = new Thread(() -> {
            log.debug("start running...");
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                log.error("InterruptedException");
            }
            log.debug("finish, {}", Thread.currentThread().isInterrupted());
        }, "t1");
        t1.start();
        Sleeper.sleep(TimeUnit.SECONDS, 1);
        log.debug("interrupt!!!!!");
        t1.interrupt();
        Sleeper.sleepMs(10);
        log.debug("t1 {}", t1.isInterrupted());

    }
}
